﻿package mortal.game.view.battlefield
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.utils.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.cache.battlefield.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.view.common.*;

    public class BattleCampScore extends GSprite
    {
        private var _forceBmp:GBitmap;
        private var _score:GTextFiled;
        private var _battlefieldScore:BattlefieldScore;
        private var _isResCompl:Boolean = false;

        public function BattleCampScore()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._forceBmp = UICompomentPool.getUICompoment(GBitmap) as GBitmap;
            this.addChild(this._forceBmp);
            this._score = UIFactory.gTextField(Language.getStringByParam(11301, "0"), 45, 0, 100, 20, this, GlobalStyle.textFormatPutong);
            LoaderHelp.addResCallBack(ResFileConst.force, this.onResCompl);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._forceBmp.dispose(param1);
            this._score.dispose(param1);
            this._forceBmp = null;
            this._score = null;
            this._battlefieldScore = null;
            this._isResCompl = false;
            return;
        }// end function

        protected function onResCompl() : void
        {
            this._isResCompl = true;
            this.draw();
            return;
        }// end function

        public function updateForceScore(param1:BattlefieldScore) : void
        {
            this._battlefieldScore = param1;
            this.draw();
            return;
        }// end function

        protected function draw() : void
        {
            var _loc_1:DefInfo = null;
            if (this._battlefieldScore && this._isResCompl)
            {
                _loc_1 = GameDefConfig.instance.getBattlefieldForceInfo(this._battlefieldScore.force);
                this._forceBmp.bitmapData = GlobalClass.getBitmapData(_loc_1.text2);
                this._score.text = Language.getStringByParam(11301, this._battlefieldScore.score.toString());
            }
            return;
        }// end function

    }
}
